﻿using ConfigHelper.Common;
using DataAccessLayer.BaseInterface;
using IDataAccessLayer;
using Model.Extend_Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataAccessLayer
{
    public class Class_ExtendDataAcessLayer : BaseDataAccessLayer<Class_Extend>, IClass_ExtendDataAcessLayer
    {
        public override string TableName
        {
            get
            {
                return "Class_Extend";
            }
        }

        public override Dictionary<string, bool> PKname
        {
            get
            {
                Dictionary<string, bool> dic = new Dictionary<string, bool>();
                dic.Add("ClassId", true);
                return dic;
            }
        }

        public List<Class_Extend> GetClassList(params SqlParameter[] param)
        {
            //调用common 中拼好的Sql语句
            string Sql = Common.GetClassList<Class_Extend>(param);

            //调用DBHelper 返回DataTable类型
            DataTable dt = DBhelper.GetDataSet(Sql);

            List<Class_Extend> Classe = new List<Class_Extend>();
            foreach (DataRow item in dt.Rows)
            {
                Class_Extend Classes = new Class_Extend();
                foreach (var i in Classes.GetType().GetProperties())
                {
                    i.SetValue(Classes, item[i.Name]);
                }
                Classe.Add(Classes);
            }
            return Classe;
        }
    }
}
